﻿/*----------------------------------------------------------------
 * 版权所有 (c) 2025 HaiTangYunchi  保留所有权利
 * CLR版本：4.0.30319.42000
 * 公司名称：
 * 命名空间：SalaryCalculator.Views
 * 唯一标识：e75cb43a-51a3-40e0-8c86-41025d10375b
 * 文件名：SettlementHistoryForm
 * 
 * 创建者：海棠云螭
 * 电子邮箱：haitangyunchi@126.com
 * 创建时间：2025/5/10 20:24:17
 * 版本：V1.0.0
 * 描述：
 *
 * ----------------------------------------------------------------
 * 修改人：
 * 时间：
 * 修改说明：
 *
 * 版本：V1.0.1
 *----------------------------------------------------------------*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace SalaryCalculator
{
    public partial class SettlementHistoryForm : Form
    {
        public SettlementHistoryForm()
        {
            InitializeComponent();
            LoadSettlementRecords();
        }

        private void LoadSettlementRecords()
        {
            // 设置DataGridView样式
            dataGridViewHistory.AutoGenerateColumns = false;
            dataGridViewHistory.Columns.Add("EmployeeName", "员工姓名");
            dataGridViewHistory.Columns["EmployeeName"].DataPropertyName = "EmployeeName";

            dataGridViewHistory.Columns.Add("DateRange", "日期范围");
            dataGridViewHistory.Columns["DateRange"].DataPropertyName = "DateRangeDisplay";

            dataGridViewHistory.Columns.Add("SettlementDate", "结算日期");
            dataGridViewHistory.Columns["SettlementDate"].DataPropertyName = "SettlementDate";
            dataGridViewHistory.Columns["SettlementDate"].DefaultCellStyle.Format = "yyyy-MM-dd";

            dataGridViewHistory.Columns.Add("TotalHours", "总工时(小时)");
            dataGridViewHistory.Columns["TotalHours"].DataPropertyName = "TotalHours";
            dataGridViewHistory.Columns["TotalHours"].DefaultCellStyle.Format = "N2";

            dataGridViewHistory.Columns.Add("TotalAmount", "总金额");
            dataGridViewHistory.Columns["TotalAmount"].DataPropertyName = "TotalAmount";
            dataGridViewHistory.Columns["TotalAmount"].DefaultCellStyle.Format = "N2";

            // 加载数据
            var repository = new SettlementRecordRepository();
            dataGridViewHistory.DataSource = repository.GetAllSettlementRecords();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}